This first code example demonstrates how to create a connection to the Access version of the Northwind database and create a property named "Orders" to which the grid will be bound. The code should be placed in the App.xaml.cs file.

VB.NET
Copy Code
Public Partial Class App
    Inherits Application
    Public Property Data As DataSet
    Public Property Orders As DataTable
    Protected Overrides Sub OnStartup(ByVal e As StartupEventArgs)
        ' Set the licence key
        Xceed.Wpf.DataGrid.Licenser.LicenseKey = "Enter your license key here"
        Data = Xceed.Wpf.DataGrid.Samples.SampleData.DataProvider.GetNorthwindDataSet()
        Orders = Data.Tables("Orders")
        MyBase.OnStartup(e)
    End Sub
End Class
C#
Copy Code
public partial class App : Application
  {
    public DataSet Data
    {
      get; set;
    }
    public DataTable Orders
    {
      get; set;
    }
    protected override void OnStartup( StartupEventArgs e )
    {
      // Set the licence key
      Xceed.Wpf.DataGrid.Licenser.LicenseKey = "Enter your license key here";
      Data = Xceed.Wpf.DataGrid.Samples.SampleData.DataProvider.GetNorthwindDataSet();
      Orders = Data.Tables[ "Orders" ];
      base.OnStartup( e );
    }
  }

The next example demonstrates how to bind a grid to the Orders table, which is retrieved through the Orders property implemented in the code above.

XAML
Copy Code
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
  <Grid.Resources>      
  <xcdg:DataGridCollectionViewSource x:Key="cvs_orders"
                                  Source="{Binding Source={x:Static Application.Current},
                                                      Path=Orders}"/>
  </Grid.Resources>
  <xcdg:DataGridControl x:Name="OrdersGrid"
                        ItemsSource="{Binding Source={StaticResource cvs_orders}}"/>
</Grid>